FastAPI 是由 :
這兩個框架作為基礎搭建的
 
 
並且 FastAPI 支援 async function
@app.get("/async")
async def async_hello_world():
    return "Hello World"
@app.get("/sync")
def sync_hello_world():
    return "Hello World"
跑起 FastAPI 後,可以在 http://localhost:port/docs 看到 Swagger UI 
在開發初期測試時非常方便!

如果喜歡 TypeScript 那一定也會喜歡 FastAPI
可以在
都可以透過 Schema 作為型別檢查的基礎 
而 Schema 就是由 Pydantic 所提供的 BaseModel  繼承而來
如下面的例子:
from datetime import datetime
from pydantic import BaseModel
class UserBase(BaseModel):
    id: int
    name: str
    country: str
    age: int
class UserCreate(UserBase):
    address: str
    birthday: datetime
    password: str
class UserPubic(UserBase):
    pass
class UserPricate(UserBase):
    address: str
    birthday: datetime
    password: str
讓我們在寫 FastAPI 時,會有寫 TypeScript 的既視感
FastAPI 之於 其他 python 後端框架架,就像 typescript 之於 javascript (單指的是語法層面)
FastAPI 的優點:
TypeScript 的感覺TestClient ,並可以透過 pytest 進行測試Github : jason810496
2023 鐵人賽 FastAPI repository
之後每天的 code 都會開在
DayXXbranch , 可以 clone 下來跑
希望可以成功完賽🔥